public class Solution1614 {
    public int maxDepth(String s) {
        int ans=0;
        int temp=0;
        for (char c:s.toCharArray()){
            if (c=='('){
                temp++;
                ans=Math.max(ans,temp);
            }else if (c==')'){
                temp--;
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1614().maxDepth("(1)+((2))+(((3)))"));
    }
}
